$ontext
===================================================================================
Name: runVSPDSetup.gms
Function: Creates the output directories and cleans up the working directory.
Developed by: Ramu Naidoo
Last modified: 01 December 2010
===================================================================================
$offtext

$include vSPDpaths.inc

* Invoke VSPDmodel - only if license type is developer (i.e. mode=0).
$if %Mode%==0    $call gams VSPDModel.gms s=VSPDModel
$if errorlevel 1 $abort +++ Check VSPDModel.lst for errors +++

* Create a couple of files.
File bat "A recyclable batch file"  / "%ProgramPath%temp.bat" / ;        bat.lw = 0 ;
File rep "Write a progess report"   / "runVSPDSetupProgress.txt" / ;     rep.lw = 0 ;

* Create and execute a batch file to:
* - remove any output directory with the extant runName;
* - create a new output directory with the extant runName;
putclose bat
  'if exist report.txt                     erase report.txt /q' /
  'if exist runVSPDSetupProgress.txt       erase runVSPDSetupProgress.txt /q' /
  'if exist runVSPDSolveProgress.txt       erase runVSPDSolveProgress.txt /q' /
  'if exist runVSPDMergeProgress.txt       erase runVSPDMergeProgress.txt /q' /
  'if exist runVSPDReportProgress.txt      erase runVSPDReportProgress.txt /q' /
  'if exist "%OutputPath%%runName%"        rmdir "%OutputPath%%runName%" /s /q' /
  'mkdir "%OutputPath%%runName%"' /
  ;
execute 'temp.bat' ;

* Indicate that runVSPDSetup is finished.
putclose rep "runVSPDSetup has now finished..." / "Time: " system.time / "Date: " system.date ;

